<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./views/js/jquery.js"></script>
    <style>
        form {
            position: relative;
        }

        input {
            position: absolute;
        }

        textarea {
            position: absolute;
            top: 30px;
        }

        button {
            position: absolute;
            left: 180px;
        }
    </style>
</head>

<body>
    <form action="#" id="fom">
        <input type="text" name="name" placeholder="输入你的用户名" autocomplete="off">
        <textarea name="con" id="con" cols="30" rows="10" placeholder="输入你的评论"></textarea>
        <button>提交</button>
    </form>

</body>
<script>
    $("button").on("click", function (e) {
        e.preventDefault();
        let myDate = new Date;
        let year = myDate.getFullYear();
        let mon = myDate.getMonth() + 1; //获取当前月
        let date = myDate.getDate();
        let hour = myDate.getHours();
        let minutes = myDate.getMinutes();
        let timestr = year + '/' + mon + '/' + date + ' ' + hour + '/' + minutes;
        $.ajax({
            url: "http://localhost:8081/pos",
            method: 'get',
            dataType: 'jsonp',
            data: {
                name: $("input[name='name']").val(),
                con: $("textarea[name='con']").val(),
                time: timestr
            },
            success: function (e) {
                if(e.code  == 200){
                    window.location.href = "E:/布卡/MyCode/NodeJs/day03/app/index.html";
                }
            }
        })
    })

</script>

</html>